#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
USER app
WORKDIR /app
EXPOSE 8080
EXPOSE 8081

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["NuGet.Config", "."]
COPY ["modules/MyModule/NuGet.Config", "modules/MyModule/"]
COPY ["modules/MyProduce/NuGet.Config", "modules/MyProduce/"]
COPY ["modules/MyEartags/NuGet.Config", "modules/MyEartags/"]
COPY ["modules/MySystemSetup/NuGet.Config", "modules/MySystemSetup/"]
COPY ["src/FinalItem.Web/FinalItem.Web.csproj", "src/FinalItem.Web/"]
COPY ["modules/MyModule/src/MyModule.Web/MyModule.Web.csproj", "modules/MyModule/src/MyModule.Web/"]
COPY ["modules/MyModule/src/MyModule.Application.Contracts/MyModule.Application.Contracts.csproj", "modules/MyModule/src/MyModule.Application.Contracts/"]
COPY ["modules/MyModule/src/MyModule.Domain.Shared/MyModule.Domain.Shared.csproj", "modules/MyModule/src/MyModule.Domain.Shared/"]
COPY ["modules/MyModule/src/MyModule.Domain/MyModule.Domain.csproj", "modules/MyModule/src/MyModule.Domain/"]
COPY ["modules/MyProduce/src/MyProduce.Web/MyProduce.Web.csproj", "modules/MyProduce/src/MyProduce.Web/"]
COPY ["modules/MyProduce/src/MyProduce.Application.Contracts/MyProduce.Application.Contracts.csproj", "modules/MyProduce/src/MyProduce.Application.Contracts/"]
COPY ["modules/MyProduce/src/MyProduce.Domain.Shared/MyProduce.Domain.Shared.csproj", "modules/MyProduce/src/MyProduce.Domain.Shared/"]
COPY ["modules/MyProduce/src/MyProduce.Domain/MyProduce.Domain.csproj", "modules/MyProduce/src/MyProduce.Domain/"]
COPY ["modules/MyEartags/src/MyEartags.Web/MyEartags.Web.csproj", "modules/MyEartags/src/MyEartags.Web/"]
COPY ["modules/MyEartags/src/MyEartags.Application.Contracts/MyEartags.Application.Contracts.csproj", "modules/MyEartags/src/MyEartags.Application.Contracts/"]
COPY ["modules/MyEartags/src/MyEartags.Domain.Shared/MyEartags.Domain.Shared.csproj", "modules/MyEartags/src/MyEartags.Domain.Shared/"]
COPY ["modules/MySystemSetup/src/MySystemSetup.Web/MySystemSetup.Web.csproj", "modules/MySystemSetup/src/MySystemSetup.Web/"]
COPY ["modules/MySystemSetup/src/MySystemSetup.Application.Contracts/MySystemSetup.Application.Contracts.csproj", "modules/MySystemSetup/src/MySystemSetup.Application.Contracts/"]
COPY ["modules/MySystemSetup/src/MySystemSetup.Domain.Shared/MySystemSetup.Domain.Shared.csproj", "modules/MySystemSetup/src/MySystemSetup.Domain.Shared/"]
COPY ["modules/MySystemSetup/src/MySystemSetup.Domain/MySystemSetup.Domain.csproj", "modules/MySystemSetup/src/MySystemSetup.Domain/"]
COPY ["src/FinalItem.Application/FinalItem.Application.csproj", "src/FinalItem.Application/"]
COPY ["src/FinalItem.Domain/FinalItem.Domain.csproj", "src/FinalItem.Domain/"]
COPY ["src/FinalItem.Domain.Shared/FinalItem.Domain.Shared.csproj", "src/FinalItem.Domain.Shared/"]
COPY ["modules/MyEartags/src/MyEartags.Domain/MyEartags.Domain.csproj", "modules/MyEartags/src/MyEartags.Domain/"]
COPY ["src/FinalItem.Application.Contracts/FinalItem.Application.Contracts.csproj", "src/FinalItem.Application.Contracts/"]
COPY ["modules/MyModule/src/MyModule.Application/MyModule.Application.csproj", "modules/MyModule/src/MyModule.Application/"]
COPY ["modules/MyProduce/src/MyProduce.Application/MyProduce.Application.csproj", "modules/MyProduce/src/MyProduce.Application/"]
COPY ["modules/MyEartags/src/MyEartags.Application/MyEartags.Application.csproj", "modules/MyEartags/src/MyEartags.Application/"]
COPY ["modules/MySystemSetup/src/MySystemSetup.Application/MySystemSetup.Application.csproj", "modules/MySystemSetup/src/MySystemSetup.Application/"]
COPY ["src/FinalItem.HttpApi/FinalItem.HttpApi.csproj", "src/FinalItem.HttpApi/"]
COPY ["modules/MyModule/src/MyModule.HttpApi/MyModule.HttpApi.csproj", "modules/MyModule/src/MyModule.HttpApi/"]
COPY ["modules/MyProduce/src/MyProduce.HttpApi/MyProduce.HttpApi.csproj", "modules/MyProduce/src/MyProduce.HttpApi/"]
COPY ["modules/MyEartags/src/MyEartags.HttpApi/MyEartags.HttpApi.csproj", "modules/MyEartags/src/MyEartags.HttpApi/"]
COPY ["modules/MySystemSetup/src/MySystemSetup.HttpApi/MySystemSetup.HttpApi.csproj", "modules/MySystemSetup/src/MySystemSetup.HttpApi/"]
COPY ["src/FinalItem.EntityFrameworkCore/FinalItem.EntityFrameworkCore.csproj", "src/FinalItem.EntityFrameworkCore/"]
COPY ["modules/MyModule/src/MyModule.EntityFrameworkCore/MyModule.EntityFrameworkCore.csproj", "modules/MyModule/src/MyModule.EntityFrameworkCore/"]
COPY ["modules/MyProduce/src/MyProduce.EntityFrameworkCore/MyProduce.EntityFrameworkCore.csproj", "modules/MyProduce/src/MyProduce.EntityFrameworkCore/"]
COPY ["modules/MyEartags/src/MyEartags.EntityFrameworkCore/MyEartags.EntityFrameworkCore.csproj", "modules/MyEartags/src/MyEartags.EntityFrameworkCore/"]
COPY ["modules/MySystemSetup/src/MySystemSetup.EntityFrameworkCore/MySystemSetup.EntityFrameworkCore.csproj", "modules/MySystemSetup/src/MySystemSetup.EntityFrameworkCore/"]
RUN dotnet restore "./src/FinalItem.Web/FinalItem.Web.csproj"
COPY . .
WORKDIR "/src/src/FinalItem.Web"
RUN dotnet build "./FinalItem.Web.csproj" -c $BUILD_CONFIGURATION -o /app/build

FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./FinalItem.Web.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "FinalItem.Web.dll"]